{% load athletelog_filters %}
{% load athletelog_tags %}
<h2>{{first_day|date:"W"}}. týden {{year}} | Tréninky</h2>
<ul class="pager_menu">
    <li class="previous"><a href="{% url athletelog.views.workout.weekly_view athlete_id=athlete.person.user.username,year=previous_year,week=previous_week %}" class="week_{{previous_year}}_{{previous_week}}">Předchozí týden</a></li>
    <li class="next"><a href="{% url athletelog.views.workout.weekly_view athlete_id=athlete.person.user.username,year=next_year,week=next_week %}" class="week_{{next_year}}_{{next_week}}">Další týden</a></li>
</ul>
<div id="weekly_view">

<table cellspacing="0">
    <thead>
        <tr>
            <th class="day">Den</th>
            <th class="phase">Fáze</th>
            <th class="type">Typ</th>
            <th class="desc">Náplň</th>
            <th class="num_data"><span class="textversion">Km/Kg/...</span></th>
        </tr>
    </thead>
    <tbody>
            {% for day_data in week_data %}
                    
                {% if day_data.workouts|length_is:"0" and day_data.competitions|length_is:"0" %}
                    {# Zadny trenink ani zavod #}
            <tr class="first_from_day first_from_phase day_{{ day_data.date|date:"Y-m-d" }}">
                    {% include 'athletelog/include/workout_weekly_day_header.html' %}
                <td colspan="4">Žádný trénink tento den...</td>
            </tr>
                {% else %}

                    {% if day_data.competitions|length_is:"0" %}
                    {# Zadny zavod, jenom treninky #}
            <tr class="first_from_day first_from_phase day_{{ day_data.date|date:"Y-m-d" }}">
                        {% include 'athletelog/include/workout_weekly_day_header.html' %}
                        {% for workout in day_data.workouts %}
                            {% include 'athletelog/include/workout_weekly_workout_row.html' %}
                        {% endfor %}
                    {% else %}

                        {% if day_data.workouts|length_is:"0" %}
                        {# Zadny trenink, jenom zavody #}
            <tr class="first_from_day competition day_{{ day_data.date|date:"Y-m-d" }}">
                            {% include 'athletelog/include/workout_weekly_day_header.html' %}
                            {% for competition in day_data.competitions %}

                                {% if forloop.first|is_not %}
                                <tr class="competition day_{{ day_data.date|date:"Y-m-d" }}">
                                {% endif %}

                                {% include 'athletelog/include/workout_weekly_competition_row.html' %}
                                </tr>
                            {% endfor %}

                        {% else %}
            <tr class="first_from_day first_from_phase day_{{ day_data.date|date:"Y-m-d" }}">
                        {% include 'athletelog/include/workout_weekly_day_header.html' %}
                        {% for workout in day_data.workouts %}
                            {% include 'athletelog/include/workout_weekly_workout_row.html' %}
                        {% endfor %}
                        {% for competition in day_data.competitions %}
                            <tr class="competition day_{{ day_data.date|date:"Y-m-d" }}">
                            {% include 'athletelog/include/workout_weekly_competition_row.html' %}
                            </tr>
                        {% endfor %}
                        {% endif %}
                    {% endif %}
                {% endif %}
            {% endfor %}
    </tbody>
</table>

</div>

<ul class="pager_menu">
    <li class="previous"><a href="{% url athletelog.views.workout.weekly_view athlete_id=athlete.person.user.username,year=previous_year,week=previous_week %}" class="week_{{previous_year}}_{{previous_week}}">Předchozí týden</a></li>
    <li class="next"><a href="{% url athletelog.views.workout.weekly_view athlete_id=athlete.person.user.username,year=next_year,week=next_week %}" class="week_{{next_year}}_{{next_week}}">Další týden</a></li>
</ul>
